<?php
    session_start();
    include 'test.php';
    
    //User tried to access without loggin in.
    $username = $_SESSION['username'];
    if($username == "")
    {
        header("Location:index.php?error=Please login first.");
    }
?>
<html>
<head>
<title>Portfolio</title>
</head>
<body>
<?php
    $portfolio = getStocks();
    foreach($portfolio as $position) {
        list($name, $shareNum, $lastDate) = explode(",",$position);
        echo "<p>" . $name . "&nbsp;" . $shareNum . "&nbsp;" . getValue($name) . "&nbsp;" . floatval($shareNum * getValue($name)) . "</p>";
    } ?>
<p>

<a href="admin.php">Click here to go back</a>
</p>
</body>
</html>    